<template>
  <div class="about">
    <h1>User login</h1>
    <form>
      <div>
        UserName: <input type="text" name="username" v-model="loginForm.username">
      </div>
      <div>
        UserName: <input type="text" name="password" v-model="loginForm.password">
      </div>
      <div>
        <button type="button" @click="login"> LOG IN</button>
      </div>
    </form>
  </div>
</template>
<script>
export default {
  data (){
    return {
      loginForm: {
        username:'wenqingwu',
        password: "123456"
      }
    }
  },
  methods: {
    login(){
      this.$axios({
        url:"/api/user/login",
        method: "post",
        data: this.loginForm
      })
      .then(res=>{
        console.log(res);
        if(res.data.code === 0){
          this.$router.push("/home")
        }else{
          alert(res.data.msg)
        }
      })
    }
  }
}
</script>
